Skip to content

Conversation

@riteshshukla04
Copy link
Contributor

@riteshshukla04 riteshshukla04 commented Dec 1, 2025

Summary:

When two different React Native libraries export a package class with the same name but in different namespaces, the generated PackageList.java causes a compilation error due to ambiguous class references.

The current autolinking generates:

import com.pikachu.NativeStorage;
import com.snowfox.NativeStorage;  // ❌ Compile error: NativeStorage is already defined

public ArrayList<ReactPackage> getPackages() {
    return new ArrayList<>(Arrays.<ReactPackage>asList(
        new MainReactPackage(mConfig),
        new NativeStorage(),  // ❌ Ambiguous reference
        new NativeStorage()   // ❌ Ambiguous reference
    ));
}

Solution:-
Use fully qualified class names (FQCN) instead of imports:

// No imports needed
public ArrayList<ReactPackage> getPackages() {
    return new ArrayList<>(Arrays.<ReactPackage>asList(
        new MainReactPackage(mConfig),
        // pikachu-storage
        new com.pikachu.NativeStorage(),
        // snowfox-storage
        new com.snowfox.NativeStorage()
    ));
}

Changelog:

[ANDROID][FIXED]- Use FQCN to avoid collisions

Test Plan:

Updated test.
Also tested on my app and RN tester
image

CI will tell if build fails

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 1, 2025
@riteshshukla04 riteshshukla04 marked this pull request as draft December 1, 2025 12:06
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Dec 1, 2025
@riteshshukla04 riteshshukla04 marked this pull request as ready for review December 1, 2025 12:06
@riteshshukla04 riteshshukla04 marked this pull request as draft December 1, 2025 12:07
@cortinico
Copy link
Contributor

This works, thanks for sending it over 👍

@riteshshukla04 riteshshukla04 marked this pull request as ready for review December 1, 2025 12:28
@riteshshukla04
Copy link
Contributor Author

@cortinico do you think we should do a change in react native cli config for this or this works?

@cortinico
Copy link
Contributor

cortinico commented Dec 2, 2025

Nope this is sufficient, we don't need a CLI PR

@meta-codesync
Copy link

meta-codesync bot commented Dec 2, 2025

@cortinico has imported this pull request. If you are a Meta employee, you can view this in D88157961.

@meta-codesync meta-codesync bot closed this in 5bb3a6d Dec 3, 2025
@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Dec 3, 2025
@meta-codesync
Copy link

meta-codesync bot commented Dec 3, 2025

@cortinico merged this pull request in 5bb3a6d.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @riteshshukla04 in 5bb3a6d

When will my fix make it into a release? | How to file a pick request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants